package com.huawei.deveco.exportprofiler;

import java.util.List;

public class ExportReqData {
    private String name;

    private String className;

    private Integer distance;

    private Integer shallowSize;

    private Integer retainedSize;

    private Integer nativeSize;

    private Integer retainedNativeSize;

    private Pagination children;

    private List<ExportReqData> retainerNodes;

    public ExportReqData(String name, String className, Integer distance, Integer shallowSize, Integer retainedSize, Integer nativeSize, Integer retainedNativeSize) {
        this.name = name;
        this.className = className;
        this.distance = distance;
        this.shallowSize = shallowSize;
        this.retainedSize = retainedSize;
        this.nativeSize = nativeSize;
        this.retainedNativeSize = retainedNativeSize;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getDistance() {
        return distance;
    }

    public void setDistance(Integer distance) {
        this.distance = distance;
    }

    public String getShallowSize() {
        return toKB(shallowSize);
    }

    public void setShallowSize(Integer shallowSize) {
        this.shallowSize = shallowSize;
    }

    public String getRetainedSize() {
        return toKB(retainedSize);
    }

    public void setRetainedSize(Integer retainedSize) {
        this.retainedSize = retainedSize;
    }

    public String getNativeSize() {
        return toKB(nativeSize);
    }

    public void setNativeSize(Integer nativeSize) {
        this.nativeSize = nativeSize;
    }

    public String getRetainedNativeSize() {
        return toKB(retainedNativeSize);
    }

    public void setRetainedNativeSize(Integer retainedNativeSize) {
        this.retainedNativeSize = retainedNativeSize;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public List<ExportReqData> getRetainerNodes() {
        return retainerNodes;
    }

    public void setRetainerNodes(List<ExportReqData> retainerNodes) {
        this.retainerNodes = retainerNodes;
    }

    public String toString() {
        return name + "," +
                distance + "," +
                toKB(shallowSize) + "," +
                toKB(retainedSize) + "," +
                toKB(nativeSize) + "," +
                toKB(retainedNativeSize) + "\n";
    }

    private String toKB(Integer sizeInByte) {
        if (sizeInByte == null) {
            return "0";
        }
        return String.format("%.2f", sizeInByte / 1024.0);
    }
}
